<!DOCTYPE html>
{% load myfilter  %}
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文章添加</title>
    <link rel="stylesheet" href="{% static 'common/css/table.css' %}">
    <link rel="stylesheet" href="{% static 'common/css/datepicker.min.css' %}"/>
    <link rel="stylesheet" href="{% static 'kin/themes/default/default.css' %}">
    <link rel="stylesheet" href="{% static 'kin/plugins/code/prettify.css' %}">
    <script src="{% static 'javascript/datepicker.min.js' %}"></script>
    <script src="{% static 'kin/kindeditor-all-min.js' %}"></script>
    <script src="{% static 'kin/plugins/code/prettify.js' %}"></script>
    <script>
        window.onload = function (){
            //窗口加载完成之后执行
            datepicker("#release_date",{
                formatter: (input, date, instance) => {
                    const now = new Date()
                    const value = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+now.getHours()+":"+now.getMinutes()
                    input.value = value // => '1/1/2099'
                },
                customDays: ['天', '一', '二', '三', '四', '五', '六'],
                customMonths: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                startDate: new Date()
            })
        }

        KindEditor.ready(function(K) {
			let editor1 = K.create('textarea[id="content"]', {
				cssPath : '/static/kin/plugins/code/prettify.css',
			});
			prettyPrint();
		});

    </script>
</head>
    {% include "inc/top.html" with title='文章列表' %}
    <table class="mytable">
        <tr><td>
            {% include "topic/inc.html" %}
        </td></tr>
    </table>
    <form action="{% url 'topic.add' %}" method="post">
    {% csrf_token %}
    <table class="mytable">
        <tbody>
        <tr>
            <td>标题</td>
            <td><input type="text" name="title" size="100"/> </td>
        </tr>
        <tr>
            <td>所属栏目</td>
            <td>
                <select name="cid">
                    {% for c in cs %}
                        <option value="{{ c.id }}">{{ c.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        <tr>
            <td>发布日期</td>
            <td><input type="text" name="release_date" id="release_date"> </td>
        </tr>
        <tr>
            <td>作者</td>
            <td><input type="text" name="author" id=""> </td>
        </tr>
        <tr>
            <td colspan="2">文章内容</td>
        </tr>
        <tr>
            <td colspan="2">
                <textarea name="content" id="content" cols="130" rows="30"></textarea>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="添加文章">
                <input type="reset" value="重置">
            </td>
        </tr>
        </tbody>
    </table>
    </form>
</body>
</html>